/* This file is part of SpaceSim.
 
 SpaceSim is free software: you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
 the Free Software Foundation, either version 3 of the License, or
 (at your option) any later version.
 
 SpaceSim is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.
 
 You should have received a copy of the GNU General Public License
 along with SpaceSim.  If not, see <http://www.gnu.org/licenses/>. */

#include <sstream>

#include "language.h"

#include "random.h"

std::string Language::RandomSystemName() {
	char vowel[] = {'a', 'e', 'e', 'i', 'o', 'u'};	// e is the most likely letter
	char cons[] = {'b', 'c', 'd', 'f', 'g', 'h', 'j', 'k', 'l', 'm', 'n', 'p', 'r', 's', 't', 'v', 'w', 'x', 'z'};
	
	std::stringstream str;
	
	bool done = false;
	
	str << cons[Random::Rand(0, 18)];	// start with a C
	
	while (!done) {
		done = Random::Rand(0, 2) == 0;	// chance of 33% to stop
		str << vowel[Random::Rand(0, 5)];	// syllable of VC
		str << cons[Random::Rand(0, 18)];
	}
	
	return str.str();
}